package com.passengerflowmanagementsystem.statistics.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.passengerflowmanagementsystem.statistics.domain.vo.*;
import com.passengerflowmanagementsystem.statistics.service.IAttentionService;
import com.passengerflowmanagementsystem.statistics.utils.GetCameraPreviewURL;
import org.springframework.stereotype.Service;

/**
 * 海康关注度Service业务层处理
 *
 * @author sheng
 * @date 2024-12-30
 */
@Service
public class AttentionServiceImpl implements IAttentionService {

    /**
     * 根据统计组id获取区域关注度相机分割区域信息
     * @param areaAreaInfoVo
     * @return
     */
    public String areaAreaInfo(AreaAreaInfoVo areaAreaInfoVo){
        String url = "/api/cfas/v2/area/areaInfo";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("countGroupId", areaAreaInfoVo.getCountGroupId());
        jsonBody.put("pageSize", areaAreaInfoVo.getPageSize());
        jsonBody.put("pageNo", areaAreaInfoVo.getPageNo());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

    /**
     * 根据统计组id获取关联的点位集合
     * @param groupCameraListVo
     * @return
     */
    public String groupCameraList(GroupCameraListVo groupCameraListVo){
        String url = "/api/cfas/v3/group/cameraList";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("ids", groupCameraListVo.getClass());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

    /**
     * 查询热度图列表
     * @return
     */
    public String heatMapList(HeatMapListVo heatMapListVo){
        String url = "/api/cfas/v1/heatMap/list";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("cameraIndexCodes", heatMapListVo.getCameraIndexCodes());
        jsonBody.put("startTime", heatMapListVo.getStartTime());
        jsonBody.put("endTime", heatMapListVo.getEndTime());
        jsonBody.put("granularity", heatMapListVo.getGranularity());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

     /**
     * 热度图下载接口
     * @param heatMapPicDownloadVo
     * @return
     */
    public String heatMapPicDownload(HeatMapPicDownloadVo heatMapPicDownloadVo){
        String url = "/api/cfas/api/v1/heatMap/picDownload";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("picUrl", heatMapPicDownloadVo.getPicUrl());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

    /**
     * 根据区域编号获取下级监控点列表
     * @param regionsRegionIndexCodeCamerasVo
     * @return
     */
    public String regionsRegionIndexCodeCameras(RegionsRegionIndexCodeCamerasVo regionsRegionIndexCodeCamerasVo){
        String url = "/api/resource/v1/regions/regionIndexCode/cameras";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("regionIndexCode", regionsRegionIndexCodeCamerasVo.getRegionIndexCode());
        jsonBody.put("pageNo", regionsRegionIndexCodeCamerasVo.getPageNo());
        jsonBody.put("pageSize", regionsRegionIndexCodeCamerasVo.getPageSize());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

    /**
     * 查询监控点列表
     * @return
     */
    public String cameraAdvanceCameraList(CameraAdvanceCameraListVo cameraAdvanceCameraListVo){
        String url = "/api/resource/v1/camera/advance/cameraList";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("pageNo", cameraAdvanceCameraListVo.getPageNo());
        jsonBody.put("pageSize", cameraAdvanceCameraListVo.getPageSize());
        jsonBody.put("cameraIndexCodes", cameraAdvanceCameraListVo.getCameraIndexCodes());
        jsonBody.put("cameraName", cameraAdvanceCameraListVo.getCameraName());
        jsonBody.put("encodeDevIndexCode", cameraAdvanceCameraListVo.getEncodeDevIndexCode());
        jsonBody.put("regionIndexCode", cameraAdvanceCameraListVo.getRegionIndexCode());
        jsonBody.put("isCascade", cameraAdvanceCameraListVo.getIsCascade());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

    /**
     * 查询监控点列表v2
     * @param cameraSearchVo
     * @return
     */
    public String cameraSearch(CameraSearchVo cameraSearchVo){
        String url = "/api/resource/v2/camera/search";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("name",cameraSearchVo.getName());
        jsonBody.put("regionIndexCodes",cameraSearchVo.getRegionIndexCodes());
        jsonBody.put("isSubRegion",cameraSearchVo.getSubRegion());
        jsonBody.put("pageNo",cameraSearchVo.getPageNo());
        jsonBody.put("pageSize",cameraSearchVo.getPageSize());
        jsonBody.put("authCodes",cameraSearchVo.getAuthCodes());
        jsonBody.put("expressions",cameraSearchVo.getExpressions());
        jsonBody.put("orderBy",cameraSearchVo.getOrderBy());
        jsonBody.put("orderType",cameraSearchVo.getOrderType());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }

    /**
     * 获取监控点在线状态
     * @param onlineCameraGetVo
     * @return
     */
    public String onlineCameraGet(OnlineCameraGetVo onlineCameraGetVo){
        String url = "/api/nms/v1/online/camera/get";
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("regionId",onlineCameraGetVo.getRegionId());
        jsonBody.put("includeSubNode",onlineCameraGetVo.getIncludeSubNode());
        jsonBody.put("indexCodes",onlineCameraGetVo.getIndexCodes());
        jsonBody.put("status",onlineCameraGetVo.getStatus());
        jsonBody.put("pageNo",onlineCameraGetVo.getPageNo());
        jsonBody.put("pageSize",onlineCameraGetVo.getPageSize());
        String body = jsonBody.toJSONString();
        return GetCameraPreviewURL.GetCameraPreviewURL(url,body);
    }
}
